package com.huixh.train.${packagePath}.controller;

import com.huixh.train.common.context.LoginMemberContext;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import com.huixh.train.${packagePath}.req.${Domain}QueryReq;
import com.huixh.train.${packagePath}.req.${Domain}SaveReq;
import com.huixh.train.${packagePath}.resp.${Domain}QueryResp;
import com.huixh.train.${packagePath}.service.${Domain}Service;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author huixh
*/
@Validated
@RestController
@RequestMapping("/admin/${domain}")
public class ${Domain}Controller {
    @Resource
    private ${Domain}Service ${domain}Service;

    @PostMapping("/save")
    public Result<?> save(@RequestBody @Valid ${Domain}SaveReq ${domain}SaveReq) {
    ${domain}Service.save(${domain}SaveReq);
        return Result.success();
    }

    @PostMapping("/quest-list")
    public PageResult<List<${Domain}QueryResp>> query(@RequestBody @Valid ${Domain}QueryReq ${domain}QueryReq) {
        return ${domain}Service.queryList(${domain}QueryReq);
    }

    @DeleteMapping("/delete/{id}")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        ${domain}Service.delete(id);
        return Result.success("删除成功");
    }
}